var $add=$("#add_button");

function save() {
    var form_data = $("#form_add").serialize();
    var b_data = decodeURIComponent(form_data, true);//防止中文乱码
    var patterndata = DataDeal.formToJson(b_data);//转化为json

    $.ajax({
        type: "post",
        url: "/pattern/save",
        contentType: "application/json;charset=utf-8",
        data: patterndata,
        success: function (data) {
            reload();
            layer.msg(data);
            $('#addDlg').modal('hide').on("hidden", function () {
                $(this).removeData("modal");
            });
            document.getElementById("form_add").reset();//重置表单
        },
        error: function (XMLHttpRequest) {
            alert("Error");
        }
    });
}
function addDlg() {
    $("#addDlg").modal();
    $.ajax({
        url:"/pattern/max",
        type:"post",
        success:function(data) {
            $('#add_rpId').val(data+1).attr('readonly', true);
        }
    });
}
$add.click(function () {
    save();
});